//
//  SCRecentPlayViewController.m
//  LastOne
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "SCRecentPlayViewController.h"
#import "SCRecentPlayView.h"
#import "CoreDataManager.h"
#import "UIImage+GaussianBlur.h"
#import "SCPlayRadio.h"
#import "FitHeader.h"
@interface SCRecentPlayViewController ()
@property(nonatomic, strong)SCRecentPlayView *recentPlayView;
@property(nonatomic, strong)NSArray *dataSourceArray;
@property(nonatomic, strong)CoreDataManager *manager;
@end

@implementation SCRecentPlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = _flagStr;
}
- (void)loadView
{
    [super loadView];
    _recentPlayView = [[SCRecentPlayView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 603 * FitHeight)];
    [self.view addSubview:_recentPlayView];

    
    _recentPlayView.userInteractionEnabled = YES;
    //[self getData];
    //高斯模糊处理时间比较长,有延时效果,放的位置要慎重
    _recentPlayView.bigImageView.image = [UIImage imageWithBlurImage:[UIImage imageNamed:@"playBackground"] intputRadius:3];
}

- (void)getData
{
    _manager = [CoreDataManager shareManager];
    //创建查询对象
    NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"SCPlayRadio"];
    _dataSourceArray = [_manager.managedObjectContext executeFetchRequest:fetchRequest error:nil];
    if (_dataSourceArray.count != 0) {
        _recentPlayView.dataSourceArray = [NSMutableArray arrayWithArray:_dataSourceArray];
    }
}

- (void)viewWillAppear:(BOOL)animated
{
    [self getData];
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
